package com.javasm.service.impl;

import com.javasm.dao.SkillGameLevelDao;
import com.javasm.entity.SkillGameLevel;
import com.javasm.service.SkillGameLevelService;
import com.javasm.utils.MyBatisHeapler;
import org.apache.ibatis.session.SqlSession;

import java.util.List;


/**
 * 技能级别(CustomerSkillGameLevel)表服务实现类
 *
 * @author makejava
 * @since 2024-08-21 16:28:23
 */

public class SkillGameLevelServiceImpl implements SkillGameLevelService {

    @Override
    public List<SkillGameLevel> listAllGameLevel(SkillGameLevel inputGameLevel, Integer page, Integer pageSize) {
        SqlSession sqlSession = MyBatisHeapler.getSqlSession();

        SkillGameLevelDao gameDao = sqlSession.getMapper(SkillGameLevelDao.class);
        List<SkillGameLevel> listGame = gameDao.listAllGameLevel(inputGameLevel,(page-1)*pageSize,pageSize);

        MyBatisHeapler.backAndSaveSqlSession(sqlSession);
        return listGame;
    }

    @Override
    public Integer countGameLevels(SkillGameLevel inputGameLevel) {
        SqlSession sqlSession = MyBatisHeapler.getSqlSession();

        SkillGameLevelDao gameDao = sqlSession.getMapper(SkillGameLevelDao.class);
        Integer total = gameDao.countGameLevels(inputGameLevel);

        MyBatisHeapler.backAndSaveSqlSession(sqlSession);
        return total;
    }

    @Override
    public Integer addGameLevel(SkillGameLevel inputGameLevel) {
        SqlSession sqlSession = MyBatisHeapler.getSqlSession();

        SkillGameLevelDao gameDao = sqlSession.getMapper(SkillGameLevelDao.class);
        Integer result = gameDao.addGameLevel(inputGameLevel);

        MyBatisHeapler.backAndSaveSqlSession(sqlSession);
        return result;
    }

    @Override
    public Integer deleteGameLevelById(Integer gameLevelId) {
        SqlSession sqlSession = MyBatisHeapler.getSqlSession();

        SkillGameLevelDao gameDao = sqlSession.getMapper(SkillGameLevelDao.class);
        Integer result = gameDao.deleteGameLevelById(gameLevelId);

        MyBatisHeapler.backAndSaveSqlSession(sqlSession);
        return result;
    }


}
